//
//  SlidCommonView.h
//  demoT
//
//  Created by 魏延龙 on 2020/7/29.
//  Copyright © 2020 魏延龙. All rights reserved.
//

#import <UIKit/UIKit.h>
@class  SlidCommonView;
NS_ASSUME_NONNULL_BEGIN

typedef enum : NSUInteger {
    SlidViewTypeCollectionView,
    SlidViewTypeTableView,
    SlidViewTypeView,
} SlidViewType;

@protocol SlidCollectionViewDataSource <NSObject>

 @required
- (NSInteger)slidCollectionView:(SlidCommonView *)slidCommonView numberOfItemsInSection:(NSInteger)section;
- (UICollectionViewCell *)slidCollectionView:(SlidCommonView *)slidCommonView cellForItemAtIndexPath:(NSIndexPath *)indexPath;
- (UICollectionReusableView *)slidCollectionView:(SlidCommonView *)slidCommonView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;
@end

@protocol SlidTableViewDataSource <NSObject>
- (NSInteger)numberOfSectionsInSlidTableView:(UITableView *)tableView;
 @required
- (NSInteger)slidTableView:(SlidCommonView *)slidCommonView numberOfItemsInSection:(NSInteger)section;
- (UITableViewCell *)slidTableView:(SlidCommonView *)slidCommonView cellForItemAtIndexPath:(NSIndexPath *)indexPath;

@end

@protocol SlidCommonViewDelegate <NSObject>

- (void)slidCommonView:(SlidCommonView *)slidCommonView didSelectItemAtIndexPath:(NSIndexPath *)indexPath;

// YES 显示导航栏   NO 隐藏导航栏   主要是返回按钮的状态变化
- (void)slidCommonView:(SlidCommonView *)slidCommonView navigationBarChangedShow:(BOOL)isShow;
// tableView 使用
-(CGFloat)slidCommonView:(SlidCommonView *)slidCommonView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

- (UIView *)slidCommonView:(SlidCommonView *)slidCommonView tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;

- (UIView *)slidCommonView:(SlidCommonView *)slidCommonView tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;

- (CGFloat)slidCommonView:(SlidCommonView *)slidCommonView tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;

- (CGFloat)slidCommonView:(SlidCommonView *)slidCommonView tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
@end


@interface SlidCommonView : UIView

// 两个数据源只能实现一个 且必须实现一个
@property (nonatomic, weak) id<SlidCollectionViewDataSource> collectionViewDataSource;
@property (nonatomic, weak) id<SlidTableViewDataSource> tableViewDataSource;

@property (nonatomic, weak) id<SlidCommonViewDelegate> slidCommonViewDelegate;

@property (nonatomic, copy) void (^footerRefreshingBlock)(void);

// 自定义导航栏标题
@property (nonatomic, copy) NSString *title;
// 上方背景图片 本地图片名字
@property (nonatomic, copy) NSString *topImageName;

// 图片上的文字标题
@property (nonatomic, copy) NSString *contentTitle;
// 图片上的文字标题行数
@property (nonatomic, assign) NSInteger contentDeseNumLines;
// 图片上的文字描述 当文字和标题只有一个的时候设置这个
@property (nonatomic, copy) NSString *contentDes;

// 上方圆形图片
@property(nonatomic, copy) NSString *badgeImageName;
// 上方圆形图片下面文字
@property(nonatomic, copy) NSAttributedString *badgeTitle;
// 内容高度
@property(nonatomic, assign) CGFloat raiseContentOffset;
// 调用这个构造方法
- (instancetype)initWithSlidViewType:(SlidViewType)type;

#pragma mark - tableview 使用
// cell 样式 tableView 使用
@property (nonatomic) UITableViewCellSeparatorStyle separatorStyle;

#pragma mark - collectionView 使用
// 设置 collectionView layout
- (void)setupSlidCollectionViewlayout:(UICollectionViewLayout *)layout;

#pragma mark - collectionView tableview 使用
- (void)registerClass:(nullable Class)cellClass forCellWithReuseIdentifier:(NSString *)identifier;
- (id)dequeueReusableCellWithReuseIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath;
- (void)deselectItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated;
- (void)reloadData;
- (void)registerClass:(nullable Class)viewClass forSupplementaryViewOfKind:(NSString *)elementKind withReuseIdentifier:(NSString *)identifier;
- (__kindof UICollectionReusableView *)dequeueReusableSupplementaryViewOfKind:(NSString *)elementKind withReuseIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath;
#pragma mark - 共用
// 单独显示View时 设置View
- (void)setupContentView:(UIView *)view;
// 设置View后 需要对view设置约束
- (void)setupTopContentView:(UIView *)view;
- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated;


#pragma mark - mjRefresh
- (void)footerHidden:(BOOL)hide;

- (void)footerEndRefreshing;


@end

NS_ASSUME_NONNULL_END
